<?php

use yii\db\Migration;
use yii\db\Schema;

class m170105_063306_create_template extends Migration
{
    public function up()
    {
        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';

        // 产品线路信息
        $this->createTable('template', [
            "id" =>          Schema::TYPE_PK,
            "cruise_id" =>   Schema::TYPE_INTEGER.    "(9) NOT NULL  COMMENT '游轮编号'",
            //"go_time" =>     Schema::TYPE_DATETIME.   " NULL COMMENT '出发时间'",
            //"return_time"=>  Schema::TYPE_DATETIME.   " NULL COMMENT '返回时间'",
            //"day" =>         Schema::TYPE_INTEGER.    "(2) DEFAULT '0' COMMENT '天数'",
            "from_city" =>   Schema::TYPE_INTEGER.    "(5) DEFAULT  '0' COMMENT '出发城市'",
            "to_city" =>     Schema::TYPE_INTEGER.    "(5) DEFAULT  '0' COMMENT '返回城市'",
            "name" =>        Schema::TYPE_STRING.     "(128) NULL COMMENT '产品名称'",
            "line" =>        Schema::TYPE_INTEGER.    "(1) DEFAULT '0' COMMENT '线路类型 : 日韩航线 中东航线...'",
            "cost" =>        Schema::TYPE_TEXT.       " NULL COMMENT '费用说明'",
            "visa" =>        Schema::TYPE_TEXT.       " NULL COMMENT '签证说明'",
            "trip" =>        Schema::TYPE_TEXT.       " NULL COMMENT '行程'",
            "status" =>      Schema::TYPE_INTEGER.    "(1) DEFAULT  '1' COMMENT '1正常  2禁用'",
            "created_at" =>  Schema::TYPE_TIMESTAMP.  " NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP",
        ], $tableOptions);
        $this->createIndex("template_cruise", "template", "cruise_id");
    }

    public function down()
    {
        $this->dropTable('template');
        echo "m170105_063306_create_template cannot be reverted.\n";

        return false;
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}
